package com.lyf.action;

import java.io.IOException;
import java.util.List;

import com.lyf.action.base.BaseAction;
import com.lyf.pojo.Employee;
import com.lyf.pojo.Information;
import com.lyf.pojo.Project;
import com.lyf.service.InformationService;
import com.lyf.util.DateUtil;
import com.lyf.util.JsonUtil;
import com.opensymphony.xwork2.Action;

public class InformationAction extends BaseAction{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private InformationService service;
	private String des;
	private Information information;
	private List<Information> informationList;
	private String id;
	
	public String execute() throws IOException{
		informationList = service.findAll();
		System.out.println(informationList);
		return Action.SUCCESS;
	}
	
	public String del(){
		service.deleteById(id);
		return null;
	}
	
	public String save() throws IOException{
		Employee employee = (Employee) getSession().get("employee");
		Project project = (Project) getSession().get("project");
		information = new Information();
		information.setI_createTime(DateUtil.getNow());
		information.setI_content(des);
		information.setEmployee(employee);
		information.setProject(project);
		
		System.out.println("des:  " + des);
		service.save(information);
		
		information.setI_content(JsonUtil.getInfoContent(employee, information,"˵:&nbsp;&nbsp;"));
		
		service.save(information);
		
		return Action.SUCCESS;
	}
	
	
	//set
	public void setService(InformationService service) {
		this.service = service;
	}

	//set,get
	public String getDes() {
		return des;
	}
	public void setDes(String des) {
		this.des = des;
	}
	public Information getInformation() {
		return information;
	}
	public void setInformation(Information information) {
		this.information = information;
	}
	public List<Information> getInformationList() {
		return informationList;
	}
	public void setInformationList(List<Information> informationList) {
		this.informationList = informationList;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	
	
	
}
